package org.atovio.mybatis.mapper;

import org.apache.ibatis.annotations.*;
import org.atovio.mybatis.pojo.ArticlePO;
import org.atovio.mybatis.provider.SQLProvider;

/**
 * @author AtoVio, Winter Yuan
 */
public interface ArticleRepository {

    /**
     * 这个方法是配置Results而设置的，没有其他意义，不让调用
     */
    @Select("")
    @Results(id = "ArticleMap", value = {
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "user_id", property = "userId"),
            @Result(column = "title", property = "title"),
            @Result(column = "create_time", property = "createTime"),
            @Result(column = "update_time", property = "updateTime"),
    })
    ArticlePO resultMap();

    /**
     * 根据id查询
     * @param id id
     * @return 记录对象
     */
    @SelectProvider(type = SQLProvider.class, method = "selectById")
    @ResultMap("ArticleMap")
    ArticlePO selectById(Integer id);
}
